//
//  SystemSettingViewController.m
//  Binfen
//
//  Created by NigasMone on 14-12-1.
//  Copyright (c) 2014年 NigasMone. All rights reserved.
//

#import "CloudPlatformViewController.h"
#import "UIViewFSLoadding.h"


@implementation CloudPlatformViewController

@synthesize link = _link;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    CGRect rc = self.view.bounds;
    // _viewNav
    rc.size.height = 35;
    _viewNav = [[UIViewNav alloc] initWithFrame:rc];
    [_viewNav.btnBack setImage:[UIImage imageNamed:@"btn-back"] forState:UIControlStateNormal];
    [_viewNav.btnBack addTarget:self action:@selector(onTouchBack) forControlEvents:UIControlEventTouchUpInside];
    _viewNav.labelTitle.text = self.title;
    [self.view addSubview:_viewNav];
    
    // _webView
    rc.origin.y = _viewNav.frame.origin.y+_viewNav.bounds.size.height;
    rc.size.height = self.view.bounds.size.height-rc.origin.y;
    _webView = [[UIWebView alloc] initWithFrame:rc];
    _webView.delegate = self;
    _webView.scalesPageToFit = YES;
    _webView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:_webView];
    
    NSURL *url = [NSURL URLWithString:_link];
    [_webView loadRequest:[NSURLRequest requestWithURL:url]];
}

#pragma mark - private
- (void)onTouchBack {
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType {
    return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [[UIViewFSLoadding shareLoadding] startWithAnimated:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [[UIViewFSLoadding shareLoadding] stopWithAnimated:YES];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [[UIViewFSLoadding shareLoadding] stopWithAnimated:YES];
}


@end
